package edu.hsbremen.teamscore.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import edu.hsbremen.teamscore.R;

public class EnterNames extends Activity {

	Button startGame;
	EditText nameTeam1;
	EditText nameTeam2;
	TextView team1Text;
	TextView team2Text;
	String gameName = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.entername);
		
		startGame = (Button) findViewById(R.id.name_button_start);
		nameTeam1 = (EditText) findViewById(R.id.name_edit_team1);
		nameTeam2 = (EditText) findViewById(R.id.name_edit_team2);
		
		Bundle bundle = getIntent().getExtras();
		gameName = bundle.getString("game");
		
		startGame.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent mIntent	= null;
				Bundle bundleNames = new Bundle();
				

				Log.d("NAME DES SPIELS", gameName);
				
				if (gameName.equals("tennis")){
					mIntent = new Intent(EnterNames.this, ScreenTennis.class);
					bundleNames.putString("team1", nameTeam1.getText().toString());
					bundleNames.putString("team2", nameTeam2.getText().toString());
				} else if(gameName.equals("floorball")){
					mIntent = new Intent(EnterNames.this, ScreenFloorball.class);
					bundleNames.putString("team1", nameTeam1.getText().toString());
					bundleNames.putString("team2", nameTeam2.getText().toString());					
				} else if(gameName.equals("soccer")){
					mIntent = new Intent(EnterNames.this, ScreenSoccer.class);
					bundleNames.putString("team1", nameTeam1.getText().toString());
					bundleNames.putString("team2", nameTeam2.getText().toString());	
				} else if(gameName.equals("basketball")){
					mIntent = new Intent(EnterNames.this, ScreenBasketball.class);
					bundleNames.putString("team1", nameTeam1.getText().toString());
					bundleNames.putString("team2", nameTeam2.getText().toString());	
				}

				mIntent.putExtras(bundleNames);
				startActivity(mIntent);
				finish();
			}
		});
	}

}
